<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../../static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../../static/js/jquery.js"></script>
<script type="text/javascript" src="../../../static/js/getParameter.js"></script>
<script type="text/javascript" src="../../../static/js/gerAllBrandName.js"></script>
<script type="text/javascript">

  let user = JSON.parse(localStorage.getItem("user"));
  var updateCType = {
    typeId:null,
    typeName:null,
    typeStatus:null,
    createId:null,
    createName:null,
    brandId:null,
  }

  function getParamCTUpdate() {
    updateCType = {
      typeId:getParameter("typeId"),
      typeName:$("#updateCType_Name").val(),
      typeStatus:$("#updateCType_Status").val(),
      createId:user.uid,
      createName:$("#updateCType_CreateName").val(),
      brandId:$("#updateCType_BName").val(),
    }
  }

  function updateCtype() {
    getParamCTUpdate();
    var isTrue = confirm("确认添加吗？");
    if (isTrue === true){
      $.ajax({
        url: "/productType/updateCType",
        method: "post",
        data: updateCType,
        dataType: "JSON",
        success: function (rel) {
          if (rel.data === true) {
            window.location.href = "ctlist";
          }
        }
      })
    }
  }

  $(function () {
    var time = new Date();
    var typeId = getParameter("typeId");
    $("#updateCType_CreateName").val(user.uname);
    $("#updateCType_CreateTime").val(time.toLocaleString());
    $.ajax({
      url:"/productType/findOneCType",
      method:"get",
      data:{typeId:typeId},
      dataType:"JSON",
      success:function (rel) {
        $("#updateCType_Name").val(rel.data.typeName);
        $("#updateCType_BName").val(rel.data.brandId);
        $("#updateCType_Status").val(rel.data.typeStatus);
      }
    })
  })

</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>商品类型管理</li>
    <li>修改</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>商品类型信息</span></div>
  <ul class="forminfo">
    <li>
      <label>品牌名称</label>
      <select class="fbtselect" id = 'updateCType_BName'>
      	  <option>请选择</option>
          <option selected="selected">联想</option>
          <option>海尔</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>商品类型名称</label>
      <input id="updateCType_Name" type="text" value="笔记本" class="dfinput" />
      <i>必填，不能超过50个字符</i>
    </li>
    <li>
      <label>状态</label>
      <select class="dfselect" id="updateCType_Status">
          <option value="1">可用</option>
          <option value="2">不可用</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>创建人</label>
      <input id="updateCType_CreateName" type="text" value="马云" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>创建时间</label>
      <input id="updateCType_CreateTime" type="text" value="2017-11-18 15:36:10" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="button" class="btn" value="确定" onclick="updateCtype()"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='ctlist'"/>
    </li>
  </ul>
</div>
</body>
</html>
